package simplyrugby.utils;

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.iv.RandomIvGenerator;

public class SecurityUtils {
    private static final String SECURITY = "lpY986+bRU1HkIzxqnX8nrs2II6Q48j4";

    private static StandardPBEStringEncryptor getEncryptor() {
        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
        encryptor.setPassword(SECURITY);
        encryptor.setIvGenerator(new RandomIvGenerator());
        return encryptor;
    }

    public static String encrypt(String plaintext) {
        return getEncryptor().encrypt(plaintext);
    }

    public static String decrypt(String ciphertext) {
        return getEncryptor().decrypt(ciphertext);
    }
}
